package org.maverickjs.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.maverickjs.application.MessageRepository;


@WebServlet("/send.do")
public class SendMessageServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
    
	
    public SendMessageServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {		
		System.out.println("-------------------------------------------------------------");
		System.out.println("Message: " + request.getParameter("message"));
		System.out.println("UserId: " + request.getParameter("userId"));
		System.out.println("UserName: " + request.getParameter("userName"));
		System.out.println("-------------------------------------------------------------");
		
		MessageRepository.getInstance().addMessage(request.getParameter("userName") + ":-> " + request.getParameter("message"));
	}

}
